package view;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class LoginWindow extends JFrame {
	JButton btnLogin;
	JButton btnCancel;
	JLabel lblName;
	JLabel lblPassword;
	JTextField txtName;
	JTextField txtPassword;
	
	/* Required for serializable interface */
	private static final long serialVersionUID = 1L;
	
	/** Constructs a new LoginWindow object */
	public LoginWindow() {
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		this.setSize(400, 200);
		this.build();		
	}
	
	/** Constructs a new LoginWindow object */
	public LoginWindow(String title) {
		super(title);
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		this.build();
	}
	
	/** Builds the window */
	public void build() {
		Container pane = this.getContentPane();
		this.setLayout(new GridLayout(3, 2));
		
		JLabel lblUserName = new JLabel("User name:");
		lblUserName.setPreferredSize(new Dimension(150, 20));
		pane.add(lblUserName);
		
		JTextField txtUserName = new JTextField();
		pane.add(txtUserName);
		
		JLabel lblPassword = new JLabel("Password:");
		pane.add(lblPassword);
		
		JPasswordField txtPassword = new JPasswordField();
		pane.add(txtPassword);
		
		JButton btnOk = new JButton("Ok");
		btnOk.addActionListener(new ButtonClickListener());
		pane.add(btnOk);
		
		JButton btnCancel = new JButton("Cancel");
		pane.add(btnCancel);
		
		this.pack();
	}
	
	/* OK button click handler */
	private void btnOkClickHandler() {
	}
	
	/* Handles button clicks */
	class ButtonClickListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			btnOkClickHandler();
		}
	}
}